package com.集合;
/*1-20之间的10个不重复的随机数*/
import java.util.Random;
import java.util.TreeSet;
import java.util.Set;
public class DifferentRandomNumber {
    public static void main(String[] args) {
//        /*无序*/Set<Integer> s = new HashSet<Integer>();
        /*有序*/Set<Integer> s = new TreeSet<Integer>();
        Random r = new Random();
        while(s.size()<=10){
            int a = r.nextInt(20)+1;
            s.add(a);
        }
        for(Integer b:s){
            System.out.println(b);
        }
    }
}
